import 'package:card_topia/design_specifications.dart';
import 'package:card_topia/main.dart';
import 'package:card_topia/pages/bind_card_page/bind_card_page.dart';
import 'package:card_topia/pages/center_page/center_page.dart';
import 'package:card_topia/pages/home_page/goods_detail_page.dart';
import 'package:card_topia/pages/login_page/verify_code_page.dart';
import 'package:card_topia/pages/profile_page/my_cards_page/my_card_detail_page.dart';
import 'package:card_topia/pages/profile_page/my_cards_page/my_cards_page.dart';
import 'package:card_topia/pages/scan_page/scan_page.dart';
import 'package:card_topia/pages/scan_page/scan_result_page.dart';
import 'package:card_topia/pages/setting_page/setting_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'pages/login_page/login_page.dart';

///路由跳转

class MyRouter{
  static BuildContext _context = globalKey.currentContext!;
  static GlobalKey<NavigatorState> globalKey = GlobalKey<NavigatorState>();
  static setContext(BuildContext context){
    _context = context;
  }
  static push({required Widget page}){
    Navigator.push(_context, MaterialPageRoute(builder: (_)=>page));
  }
  static pushName({required String name,dynamic arguments}){
    Navigator.pushNamed(_context,name,arguments: arguments);
  }
  static pop([dynamic args]){
    Navigator.pop(_context, args);
  }
  static replace({required Widget page}){
    Navigator.pushReplacement(_context,MaterialPageRoute(builder: (_)=>page));
  }

  static Map<String,Widget Function(BuildContext context)> routes = {
    root:(context)=>MyHomePage(),
    settingPage:(context)=>SettingPage(),
    verifyCodePage:(context){
      final args = _getArgs(context);
      return VerifyCodePage(email: args['email']);
    }
  };

  static _getArgs(BuildContext context){
    return ModalRoute.of(context)!.settings.arguments;
  }
  static const root = "/";
  static const verifyCodePage = "/verifyCodePage";
  static const loginPage = "/loginPage";
  static const settingPage = "/settingPage";
  static const centerPage = "/centerPage";
  static const bindCardPage = "/bindCardPage";
  static const scanPage = "/scanPage";
  static const scanResultPage = "/scanResultPage";
  static const goodsDetailPage = "/goodsDetailPage";
  static const myCardsPage = "/myCardsPage";
  static const myCardDetailPage = "/myCardDetailPage";

}
